﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace Dexter.DataTransferObject {
	public class PageStructureDto {
		public int Id { get; set; }
		public string Title { get; set; }
		public string Slug { get; set; }
		public bool IsPublished { get; set; }
		public int SortOrder { get; set; }
		public IEnumerable<PageStructureDto> Pages { get; set; }

		public virtual ReadOnlyCollection<PageStructureDto> SortedPages
		{
			get
			{
				if (Pages != null)
					return new ReadOnlyCollection<PageStructureDto>(Pages.OrderBy(p => p.SortOrder).ToList());

				return new ReadOnlyCollection<PageStructureDto>(new List<PageStructureDto>());
			}
		}
	}
}
